package com.example.administrator.autofittextview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

import com.example.administrator.autofittextview.Widget.AutoFitTextView;

public class MainActivity extends AppCompatActivity {
    private TextView mOutput;
    private AutoFitTextView  mAutofitOutput;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mOutput = (TextView)findViewById(R.id.output);
        mAutofitOutput = (AutoFitTextView)findViewById(R.id.output_autofit);

        mAutofitOutput.setOnTextSizeChangeListener(new AutoFitTextView.OnTextSizeChangeListener() {
            @Override
            public boolean onTextSizeChange() {

                return false;
            }
        });
        ((EditText)findViewById(R.id.input)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                // do nothing
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                mOutput.setText(charSequence);
                mAutofitOutput.setText(charSequence);
            }

            @Override
            public void afterTextChanged(Editable editable) {
                // do nothing
            }
        });
    }
}
